package com.heyun.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.heyun.bean.HeyunSalesAnal;
import com.heyun.bean.HeyunSalesDeptAnal;
import com.heyun.bean.HeyunSalesPlan;
import com.heyun.bean.HeyunSalesPre;
import com.heyun.dao.SalesAnalDao;
import com.heyun.service.SalesAnalService;
@Service
public class SalesAnalServiceImpl implements SalesAnalService {
	@Autowired
	private SalesAnalDao  salesanalfdao;

	@Override
	public Map<String, Object> getSalesAnal(int currentPage) {
		// TODO Auto-generated method stub
		
		PageHelper.startPage(currentPage,3);//每一页显示三条数据
		//获取所有销售计划的集合
		List<HeyunSalesAnal> hsalist=salesanalfdao.getSalesAnal();
	   
		PageInfo<HeyunSalesAnal> p=new PageInfo<HeyunSalesAnal>(hsalist);
		
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("hsalist", hsalist);
		map.put("totalPage", p.getPages());
	
		System.out.println("总页数是==="+p.getPages());
		return map;
	}

	@Override
	public Map<String, Object> getSalesDeptAnal(int salesMonthAnalId,
			int currentPage) {
		System.out.println("==========进来了没======="+currentPage);
		
		PageHelper.startPage(currentPage,4);//每一页显示三条数据
		List<HeyunSalesDeptAnal> hsdalist=salesanalfdao.getSalesDeptAnal(salesMonthAnalId);
		
		PageInfo<HeyunSalesDeptAnal> p=new PageInfo<HeyunSalesDeptAnal>(hsdalist);
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("hsdalist", hsdalist);
		map.put("totalPage", p.getPages());
		return map;
	}

	@Override
	public List<HeyunSalesDeptAnal> getSalesDeptAnal(int salesMonthAnalId) {
		// TODO Auto-generated method stub
		List<HeyunSalesDeptAnal> hsdalist=salesanalfdao.getSalesDeptAnal(salesMonthAnalId);
        for(HeyunSalesDeptAnal hsda:hsdalist){
        	System.out.println(hsda.getDeptName());
        }
		return hsdalist;
	}

	@Override
	public Map<String, Object> findSalesAnalByMonth(int currentPage,
			String month) {
		PageHelper.startPage(currentPage,3);//每一页显示三条数据
		List<HeyunSalesAnal> anallist=salesanalfdao.findSalesAnalByMonth(month);
		PageInfo<HeyunSalesAnal> p=new PageInfo<HeyunSalesAnal>(anallist);
	
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("anallist", anallist);
		for(HeyunSalesAnal anal:anallist){
			System.out.println("销售金额====="+anal.getSalesMoney());
		}
		map.put("totalPage", p.getPages());
		return map;
	}



	
}
